/*
 * Author: Andy Johnson
 */
package tests;

import static org.junit.Assert.*;

import java.util.HashMap;

import model.Job;
import model.Jobs;
import model.LMA;
import model.Volunteer;
import model.System;

import org.junit.Before;
import org.junit.Test;

import util.Stringer;

/**
 * The JUnit class for SystemTest.
 */
public class SystemTest {

	/** The my system. */
	System mySystem;
	
	Jobs myJobs;
	
	Job myJob1;

	LMA Frank;

	@SuppressWarnings("unused")
	private static util.Stringer theStringer;
	
	/**
	 * Sets the up.
	 *
	 * @throws Exception the exception
	 * @author Andy Johnson
	 */
	@Before
	public void setUp() throws Exception {
		theStringer = new Stringer();
		mySystem = new System();
		myJobs = new Jobs();
		myJob1 = new Job(Stringer.getString(43), 
				Integer.parseInt(Stringer.getString(44)), 
				Integer.parseInt(Stringer.getString(45)), 
				Frank,
				Integer.parseInt(Stringer.getString(46)), 
				Integer.parseInt(Stringer.getString(47)), 
				Stringer.getString(48));
		Frank = new LMA(Stringer.getString(49), 
						Stringer.getString(50), 
						Stringer.getString(51), 
						Stringer.getString(52), 
						Stringer.getString(53),
						Stringer.getString(54), 
						Stringer.getString(55), 
						Stringer.getString(56), 
						null);
		
	}

	/**
	 * Test login.
	 * 
	 * @author Andy Johnson
	 */
	@Test
	public final void testLogin() {
		assertTrue(mySystem.login(Stringer.getString(57), 
				Stringer.getString(58)));
		assertTrue(mySystem.login(Stringer.getString(59), 
				Stringer.getString(60)));
		assertTrue(mySystem.login(Stringer.getString(61), 
				Stringer.getString(62)));
		assertFalse(mySystem.login(null, 
				Stringer.getString(63)));
		assertFalse(mySystem.login(Stringer.getString(64), 
				null));
	}

	/**
	 * Test register volunteer.
	 * 
	 * @author Andy Johnson
	 */
	@Test
	public final void testRegisterVolunteer() {
		mySystem.register(new Volunteer(Stringer.getString(65), 
				Stringer.getString(66), 
				Stringer.getString(67), 
				Stringer.getString(68), 
				Stringer.getString(69), 
				Stringer.getString(70), 
				Stringer.getString(71)));
		assert(
			mySystem.getUsers().findUser(
					Stringer.getString(72)) != null);
	}

	/**
	 * Test register lma.
	 * @author Peter Mosher
	 */
	@Test
	public final void testRegisterLMA() {
		mySystem.register(new LMA(Stringer.getString(73), 
				Stringer.getString(74), 
				Stringer.getString(75), 
				Stringer.getString(76), 
				Stringer.getString(77), 
				Stringer.getString(78), 
				Stringer.getString(79), null, null));
		assert(
			mySystem.getUsers().findUser(Stringer.getString(80)) != null);
	}

	/**
	 * Test add request.
	 * 
	 * @author Justin Kudlo
	 */
	@Test
	public final void testAddRequest() {
		myJobs.addNewRequest(myJob1);
		HashMap<String, Job> theRequestedJobs = myJobs.
		getRequestedJobs();
		assertEquals(theRequestedJobs.containsKey(myJob1.
				getName()), true);
	}

	/**
	 * Test get scheduler info.
	 * @author Peter Mosher
	 */
	@Test
	public final void testGetSchedulerInfo() {
		String info = mySystem.getSchedulerInfo();
		String shouldbe = Stringer.getString(81)+ "\n"+ 
						  Stringer.getString(82) +"\n" + 
						  Stringer.getString(83);
		String notsame = Stringer.getString(84);
		assertTrue(info.equals(shouldbe));
		assertTrue(shouldbe.equals(info));
		assertFalse(info.equals(notsame));
		assertFalse(notsame.equals(info));
	}

}
